home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / tip / boxrqu.tip < prev    next >
Text File  |  1993-09-15  |  4KB  |  119 lines

  1. % This macro source file is from the four volume series
  2. % "TeX in Practice" by Stephan von Bechtolsheim, published
  3. % 1993 by Springer-Verlag, New York.
  4. % Copyright 1993 Stephan von Bechtolsheim.
  5. % No warranty or liability is assumed.
  6. % This macro may be copied freely if no fees other than
  7. % media cost or shipping charges are charged and as long
  8. % as this copyright and the following source code itself
  9. % is not changed. Please see the series for further information.
  10. %
  11. % Version: 1.0
  12. % Date: May 1, 1993
  13. %
  14. %
  15. % This source code is documented in 27.3.2, p. III-424.
  16. % Original source in file "macros7.TEX", starting line 1362.
  17. \wlog{L: "boxrqu.tip" ["macros7.TEX," l. 1362, p. III-424]}%
  18. % This file DOES belong to format "texip."
  19. \InputD{namedef.tip}
  20. \InputD{doloop.tip}
  21. \InputD{newoutfr.tip}
  22. \InputD{mspaces.tip}
  23. \catcode`\@ = 11
  24. \newcount\@BoxRQStart
  25. \newcount\@BoxRQEnd
  26. \newcount\@BoxRQLength
  27. \newcount\@BoxRQCount
  28. \newcount\@BoxRQLast
  29. \newcount\@BoxRQFirst
  30. \def\@LoadBRQCounters #1{%
  31.     \if\NameDefinedConditional{@BoxRQ-Start-#1}%
  32.         \@BoxRQStart = \NameUse{@BoxRQ-Start-#1}%
  33.         \@BoxRQEnd   = \NameUse{@BoxRQ-End-#1}%
  34.         \@BoxRQLength= \NameUse{@BoxRQ-Length-#1}%
  35.         \@BoxRQCount = \NameUse{@BoxRQ-Count-#1}%
  36.         \@BoxRQLast  = \NameUse{@BoxRQ-Last-#1}%
  37.         \@BoxRQFirst = \NameUse{@BoxRQ-First-#1}%
  38.     \else
  39.         \errmessage{\string\@LoadBRQCounters: no queue "#1".}%
  40.     \fi
  41. }
  42. \def\@RestoreBRQCounters #1{%
  43.     \NameXdef{@BoxRQ-Start-#1}{\the\@BoxRQStart}%
  44.     \NameXdef{@BoxRQ-End-#1}{\the\@BoxRQEnd}%
  45.     \NameXdef{@BoxRQ-Length-#1}{\the\@BoxRQLength}%
  46.     \NameXdef{@BoxRQ-Count-#1}{\the\@BoxRQCount}%
  47.     \NameXdef{@BoxRQ-Last-#1}{\the\@BoxRQLast}%
  48.     \NameXdef{@BoxRQ-First-#1}{\the\@BoxRQFirst}%
  49. }
  50. \newcount\@BoxRQTempA           \newcount\@BoxRQTempB
  51. \def\SetUpBoxRegisterQueue #1#2{% 
  52.     \@BoxRQStart = \count14
  53.     \advance\@BoxRQStart by 1
  54.     \@BoxRQTempA = \@BoxRQStart
  55.     \DoLoop{\@BoxRQTempB}{1}{1}{#2}% 
  56.         {\newboxOF\@WhoCaresBoxRegisterIndexA
  57.         \advance\@BoxRQTempA by 1 }
  58.     \advance\@BoxRQTempA by -1
  59.     \@BoxRQEnd = \@BoxRQTempA
  60.     \wlog{\string\SetUpBoxRegisterQueue: queue "#1."}%
  61.     \wlog{\EightSpaces Box registers
  62.         \the\@BoxRQStart\space through
  63.         \the\@BoxRQEnd\space allocated.}%
  64.     \wlog{\EightSpaces (#2 registers).}%
  65.     \@BoxRQCount = 0
  66.     \@BoxRQLength = #2
  67.     \@RestoreBRQCounters{#1}%
  68. }
  69. \def\AddBoxToQueue #1#2{% 
  70.     \@LoadBRQCounters{#1}%
  71.     \wlog{\string\AddBoxToQueue: length: \the\@BoxRQLength,
  72.         count: \the\@BoxRQCount}%
  73.     \ifnum\@BoxRQCount  = \@BoxRQLength
  74.         \errmessage{\string\AddBoxToQueue: Queue "#1" is full.}% 
  75.     \else
  76.         \ifnum\@BoxRQCount = 0
  77.             \@BoxRQLast  = \@BoxRQStart
  78.             \@BoxRQFirst = \@BoxRQStart
  79.         \fi
  80.         \global\setbox\@BoxRQLast = #2%
  81.         \advance\@BoxRQLast by 1
  82.         \ifnum\@BoxRQLast > \@BoxRQEnd
  83.             \@BoxRQLast = \@BoxRQStart
  84.         \fi
  85.         \advance\@BoxRQCount by 1
  86.         \@RestoreBRQCounters{#1}%
  87.     \fi
  88. }
  89. \def\CopyFirstElementFromQueue #1#2{% 
  90.     \@LoadBRQCounters{#1}%
  91.     \ifnum\@BoxRQCount = 0
  92.         \errmessage{\string\CopyFirstElementFromQueue: empty "#1"}%
  93.     \else
  94.         \setbox #2 = \copy\@BoxRQFirst
  95.     \fi
  96. }
  97. \def\DropFirstBoxOfQueue #1{% 
  98.     \@LoadBRQCounters{#1}%
  99.     \ifnum\@BoxRQCount = 0
  100.         \errmessage{\string\DropFirstBoxOfQueue: "#1" is empty.}% 
  101.     \else
  102.         \advance\@BoxRQCount by -1
  103.         \ifnum\@BoxRQCount = 0
  104.         \else
  105.             \advance\@BoxRQFirst by 1
  106.             \ifnum\@BoxRQFirst > \@BoxRQEnd
  107.                 \@BoxRQFirst = \@BoxRQStart
  108.             \fi
  109.         \fi
  110.     \fi
  111.     \@RestoreBRQCounters{#1}%
  112. }
  113. \def\EmptyBoxRegisterQueueConditional #1{% 
  114.     TT\fi
  115.     \@LoadBRQCounters{#1}%
  116.     \ifnum\@BoxRQCount = 0
  117. }
  118. \catcode`\@ = 12
  119.